//
//  YeeCollectionTableViewCell.m
//  YeeShopProject
//
//  Created by CoderYee on 2017/3/7.
//  Copyright © 2017年 CoderYee. All rights reserved.
//

#import "YeeCollectionTableViewCell.h"
#import "YeeCollectionEntity.h"

@interface YeeCollectionTableViewCell ()
{
    UIView  *_centerView;
    
}

@end
@implementation YeeCollectionTableViewCell

-(void)addOwnView
{
    [self setBackgroundColor:xBackgroundColor];
    _centerView=[[UIView alloc] init];
    _centerView.layer.masksToBounds=YES;
    _centerView.layer.cornerRadius=3.0f;
    _centerView.layer.borderWidth=0.01;
    _centerView.layer.borderColor=kGrayColor.CGColor;
    [self.contentView addSubview:_centerView];
    [_centerView setBackgroundColor:kWhiteColor];
    [_centerView mas_makeConstraints:^(MASConstraintMaker *make)
    {  make.left.equalTo(self.contentView).with.offset(40);
        make.right.equalTo(self.contentView).with.offset(-40);
        make.top.bottom.equalTo(self.contentView);
    }];
    
    _coverView=[[UIImageView alloc] init];
    _coverView.contentMode=UIViewContentModeScaleAspectFill;
    _coverView.clipsToBounds=YES;
    _coverView.layer.masksToBounds=YES;
    _coverView.layer.cornerRadius=15.0f;
    [_centerView addSubview:_coverView];
    [_coverView setImage:[UIImage imageNamed:@"bg_event_img_placeholder"]];
    [_coverView mas_makeConstraints:^(MASConstraintMaker *make)
     {
        make.left.top.equalTo(_centerView).with.offset(5.0);
        make.height.width.mas_equalTo(30);
    }];

    _autorLable=[[UILabel alloc] init];
    _autorLable.text=@"作者的标题";
    _autorLable.font=[UIFont Y_systemFontOfSize:10];
    [_centerView addSubview:_autorLable];
    [_autorLable mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(_coverView.mas_right).offset(10);
         make.centerY.equalTo(_coverView.mas_centerY);
         make.height.mas_equalTo(21);
    }];
    
    _describeLable=[[UILabel alloc] init];
    _describeLable.text=@"描述描述描述描述描述描述描述描述描述描述述描述描述描述描述描述描述描述描述描";
    _describeLable.font=[UIFont Y_systemFontOfSize:12];
    _describeLable.numberOfLines=0;
    [_centerView addSubview:_describeLable];
    [_describeLable mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(_coverView.mas_bottom).offset(10);
         make.left.right.equalTo(_centerView);
         //make.bottom.equalTo(_centerView).with.offset(-10);
     }];

   
}
//-(void)setEntity:(YeeCollectionEntity *)Entity
//{
//    _Entity=Entity;
//    _autorLable.text=Entity.title;
//    [_coverView sd_setImageWithURL:[NSURL URLWithString:Entity.image] placeholderImage:[UIImage imageNamed:@"bg_event_img_placeholder"]];
//    _describeLable.text=Entity.author_intro;
//}
-(void)bindViewModel
{
    
    [super bindViewModel];
    @weakify(self);
    [RACObserve(self, Entity) subscribeNext:^(YeeCollectionEntity *model) {
        
        @strongify(self);
        self.autorLable.text=model.title;
        [self.coverView sd_setImageWithURL:[NSURL URLWithString:model.image] placeholderImage:[UIImage imageNamed:@"bg_event_img_placeholder"]];
        self.describeLable.text=model.author_intro;
        
    } ];
    
   // RAC(_coverView,image)=RACObserve(<#TARGET#>, <#KEYPATH#>);
   //     RAC(_autorLable,text)=[[RACObserve(_Entity, title) distinctUntilChanged ] takeUntil:<#(nonnull RACSignal *)#>];

    
    
}
@end
